home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kwinmodule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-01  |  10.3 KB  |  359 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org)
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.     Boston, MA 02110-1301, USA.
  18. */
  19. /*
  20.  * kwinmodule.h. Part of the KDE project.
  21.  */
  22.  
  23. #ifndef KWINMODULE_H
  24. #define KWINMODULE_H
  25.  
  26. #include <qobject.h>
  27. #include <qvaluelist.h>
  28. #include "kdelibs_export.h"
  29.  
  30. #ifdef Q_OS_UNIX
  31.  
  32. class KWinModulePrivate;
  33.  
  34. /**
  35.  *
  36.  * The class KWinModule provides information about the state of the
  37.  * window manager as required by windowmanager modules. It informs a
  38.  * module about all currently managed windows and changes to them (via
  39.  * Qt signals).
  40.  *
  41.  * KWinModule uses NETRootInfo internally. Modules written with this
  42.  * class will work fine under any window manager that implements the
  43.  * NET_WM protocol.
  44.  *
  45.  * There are no methods to manipulate windows. Those are defined in
  46.  * the classes KWin, NETWinInfo and NETRootInfo.
  47.  *
  48.  *
  49.  * @short Base class for KDE Window Manager modules.
  50.  * @author Matthias Ettrich (ettrich@kde.org)
  51.  */
  52. class KDECORE_EXPORT KWinModule : public QObject
  53. {
  54.     Q_OBJECT
  55.  
  56. public:
  57.  
  58.     enum { INFO_DESKTOP=1,
  59.            INFO_WINDOWS=2,
  60.            INFO_ALL=32767 };
  61.     /**
  62.      * Creates a KWinModule object and connects to the window
  63.      * manager.
  64.      * @param parent the parent for the QObject
  65.      * @param what The information you are interested in:
  66.      *   INFO_DESKTOP:  currentDesktop, 
  67.      *                  numberOfDesktops, 
  68.      *                  desktopName, 
  69.      *                  currentDesktopChanged, 
  70.      *                  numberOfDesktopsChanged, 
  71.      *                  desktopNameChanged,
  72.      *                  activeWindow,
  73.      *                  activeWindowChanged,
  74.      *                  workArea(int desktop),
  75.      *                  workAreaChanged
  76.      *
  77.      *   INFO_WINDOWS:  windows,
  78.      *                  windowAdded,
  79.      *                  windowRemoved,
  80.      *                  stackingOrder,
  81.      *                  systemTrayWindows,
  82.      *                  systemTrayWindowAdded,
  83.      *                  systemTrayWindowRemoved,
  84.      *                  windowChanged,
  85.      *                  strutChanged,
  86.      *                  workArea(const QValueList<WId> &excludes, int desktop)
  87.      **/
  88.     KWinModule( QObject* parent, int what );
  89.     /**
  90.      * Creates a KWinModule object and connects to the window
  91.      * manager.
  92.      * @param parent the parent for the QObject
  93.      **/
  94.     KWinModule( QObject* parent = 0 );
  95.  
  96.     /**
  97.      * Destructor. Internal cleanup, nothing fancy.
  98.      **/
  99.     ~KWinModule();
  100.  
  101.     /**
  102.      * Returns the list of all toplevel windows currently managed by the
  103.      * window manager in the order of creation. Please do not rely on
  104.      * indexes of this list: Whenever you enter Qt's event loop in your
  105.      * application, it may happen that entries are removed or added.
  106.      * Your module should perhaps work on a copy of this list and verify a
  107.      * window with hasWId() before any operations.
  108.      *
  109.      * Iteration over this list can be done easily with
  110.      * \code
  111.      *  QValueList<WId>::ConstIterator it;
  112.      *  for ( it = module->windows().begin();
  113.      *        it != modules->windows().end(); ++it ) {
  114.      *     ... do something here,  (*it) is the current WId.
  115.      *       }
  116.      * \endcode
  117.      * @return the list of all toplevel windows
  118.      */
  119.     const QValueList<WId>& windows() const;
  120.  
  121.     /**
  122.      * Returns the list of all toplevel windows currently managed by the
  123.      * window manager in the current stacking order (from lower to
  124.      * higher). May be useful for pagers.
  125.      * @return the list of all toplevel windows in stacking order
  126.      */
  127.     const QValueList<WId>& stackingOrder() const;
  128.  
  129.     /**
  130.      * Test to see if @p id still managed at present.
  131.      * @param id the window id to test
  132.      * @return true if the window id is still managed
  133.      **/
  134.     bool hasWId(WId id) const;
  135.  
  136.     /**
  137.      * Returns a list of the system tray windows.
  138.      * @return a list of all system tray windows
  139.      **/
  140.     const QValueList<WId>& systemTrayWindows() const;
  141.  
  142.     /**
  143.      * Returns the current virtual desktop.
  144.      * @return the current virtual desktop
  145.      **/
  146.     int currentDesktop() const;
  147.  
  148.     /**
  149.      * Returns the number of virtual desktops.
  150.      * @return the number of virtual desktops
  151.      **/
  152.     int numberOfDesktops() const;
  153.  
  154.     /**
  155.      * Returns the number of viewports in x and y direction
  156.      * on the virtual desktop.
  157.      * @return the number of virtual desktops
  158.      * @since 3.5.5
  159.      **/
  160.     QSize numberOfViewports(int desktop) const;
  161.  
  162.     /**
  163.      * Returns the current viewport on the given virtual desktop
  164.      * @return the number of virtual desktops
  165.      * @since 3.5.5
  166.      **/
  167.     QPoint currentViewport(int desktop) const;
  168.  
  169.     /**
  170.      * Returns the currently active window, or 0 if no window is active.
  171.      * @return the window id of the active window, or 0 if no window is 
  172.      *  active
  173.      **/
  174.     WId activeWindow() const;
  175.  
  176.     /**
  177.      * Returns the workarea for the specified desktop, or the current
  178.      * work area if no desktop has been specified.
  179.      * @param desktop the number of the desktop to check, -1 for the
  180.      *        current desktop
  181.      * @return the size and position of the desktop
  182.      **/
  183.     QRect workArea( int desktop = - 1 ) const;
  184.  
  185.  
  186.     /**
  187.      * Returns the workarea for the specified desktop, or the current
  188.      * work area if no desktop has been specified. Excludes struts of
  189.      * clients in the exclude List.
  190.      *
  191.      * @param excludes the list of clients whose struts will be excluded
  192.      * @param desktop the number of the desktop to check, -1 for the
  193.      *        current desktop
  194.      * @return the size and position of the desktop
  195.      **/
  196.     QRect workArea( const QValueList<WId> &excludes, int desktop = -1) const;
  197.  
  198.     /**
  199.      * Returns the name of the specified desktop.
  200.      * @param desktop the number of the desktop
  201.      * @return the name of the desktop
  202.      **/
  203.     QString desktopName( int desktop ) const;
  204.  
  205.     /**
  206.      * Sets the name of the specified desktop.
  207.      * @param desktop the number of the desktop
  208.      * @param name the new name for the desktop
  209.      **/
  210.     void setDesktopName( int desktop, const QString& name );
  211.  
  212.     /**
  213.      * Returns the state of showing the desktop.
  214.      * @since 3.5
  215.      */
  216.     bool showingDesktop() const;
  217.  
  218.     /**
  219.      * Informs kwin via dcop to not manage a window with the
  220.      * specified @p title.
  221.      *
  222.      * Useful for swallowing legacy applications, for example java
  223.      * applets.
  224.      *
  225.      * @param title the title of the window
  226.      */
  227.     void doNotManage( const QString& title );
  228.  
  229.  
  230. signals:
  231.  
  232.     /**
  233.      * Switched to another virtual desktop.
  234.      * @param desktop the number of the new desktop
  235.      */
  236.     void currentDesktopChanged( int desktop);
  237.  
  238.     /**
  239.      * A window has been added.
  240.      * @param id the id of the the window 
  241.      */
  242.     void windowAdded(WId id);
  243.  
  244.     /**
  245.      * A window has been removed.
  246.      * @param id the id of the window that has been removed
  247.      */
  248.     void windowRemoved(WId id);
  249.  
  250.     /**
  251.      * Hint that \<Window> is active (= has focus) now.
  252.      * @param id the id of the window that is active
  253.      */
  254.     void activeWindowChanged(WId id);
  255.  
  256.     /**
  257.      * Desktops have been renamed.
  258.      */
  259.     void desktopNamesChanged();
  260.  
  261.     /**
  262.      * The number of desktops changed.
  263.      * @param num the new number of desktops
  264.      */
  265.     void numberOfDesktopsChanged(int num);
  266.  
  267.     /**
  268.      * Emitted when a dock window has been added.
  269.      * @param id the id of the new system tray window
  270.      */
  271.     void systemTrayWindowAdded(WId id);
  272.  
  273.     /**
  274.      * Emitted when a dock window has been removed.
  275.      * @param id the id of the former system tray window
  276.      */
  277.     void systemTrayWindowRemoved(WId id);
  278.  
  279.     /**
  280.      * The workarea has changed.
  281.      */
  282.     void workAreaChanged();
  283.  
  284.     /** 
  285.      * Something changed with the struts, may or may not have changed
  286.      * the work area. Usually just using the workAreaChanged() signal
  287.      * is sufficient.
  288.      */
  289.     void strutChanged();
  290.     
  291.     /**
  292.      * Emitted when the stacking order of the window changed. The new order
  293.      * can be obtained with stackingOrder().
  294.      */
  295.     void stackingOrderChanged();
  296.  
  297.  
  298.     /**
  299.      * The window changed.
  300.      *
  301.      * The properties parameter contains the NET properties that
  302.      * were modified (see netwm_def.h). First element are NET::Property
  303.      * values, second element are NET::Property2 values (i.e. the format
  304.      * is the same like for the NETWinInfo class constructor).
  305.      * @param id the id of the window
  306.      * @param properties the properties that were modified
  307.      */
  308.     void windowChanged(WId id, const unsigned long* properties );
  309.  
  310.     /**
  311.      * @deprecated
  312.      * The window changed.
  313.      *
  314.      * The unsigned int parameter contains the NET properties that
  315.      * were modified (see netwm_def.h).
  316.      * @param id the id of the window
  317.      * @param properties the properties that were modified
  318.      */
  319.     void windowChanged(WId id, unsigned int properties);
  320.  
  321.     /**
  322.      * The window changed somehow.
  323.      * @param id the id of the window
  324.      */
  325.     void windowChanged(WId id);
  326.  
  327.     /**
  328.      * The state of showing the desktop has changed.
  329.      * @since 3.5
  330.      */
  331.     void showingDesktopChanged( bool showing );
  332.  
  333.     /**
  334.      * The state of showing the desktop has changed.
  335.      * @since 3.5.5
  336.      */
  337.     void desktopGeometryChanged(int desktop);
  338.  
  339.     /**
  340.      * The viewport position has changed
  341.      * @since 3.5
  342.      */
  343.     void currentDesktopViewportChanged(int desktop, const QPoint& viewport);
  344.  
  345. protected:
  346.     virtual void connectNotify( const char* signal );
  347.  
  348. private:
  349.     void init(int);
  350.  
  351.     KWinModulePrivate* d;
  352.  
  353.     friend class KWinModulePrivate;
  354. };
  355.  
  356. #endif //Q_OS_UNIX
  357.  
  358. #endif
  359.